package com.example.hwqgroovygradle.ui.reflect

import android.app.Activity
import com.example.hwqlibannotations.BindView

class ReflectBinding {
    companion object {
        fun bind(activity: Activity) {
            for (field in activity.javaClass.declaredFields) {
                val bindView: BindView? = field.getAnnotation(BindView::class.java)
                bindView?.let {
                    try {
                        field.isAccessible = true
                        field[activity] = activity.findViewById(it.value)
                    } catch (e: Exception) {
                        e.printStackTrace()
                    }
                }
            }
        }
    }

}